var computerIP = '192.168.xxx.xxx'

var projectName = 'autojsProject'

downLoad(projectName)
sleep(2000)
runProject()
function runProject() {
	var filePath = files.join(files.getSdcardPath(), '脚本', projectName, 'index.js')
	console.log('filePath=')
	console.log(filePath)
	engines.execScriptFile(filePath, { path: files.join(files.getSdcardPath(), '脚本', projectName) })
}
function downLoad(projectName) {
	var projectFileList = getProjectFileList(projectName)
	log('projectFileList=')
	log(projectFileList)
	projectFileList.map(filePath => {
		downloadFile(filePath)
	})
}
function downloadFile(filePath) {
	var url = util.format('http://%s:3000/fileSync/project/file/%s', computerIP, filePath)
	url = url.replace(/\s/g, '')
	console.log(url)
	var r = http.get(url)
	r = r.body.bytes()
	files.createWithDirs(filePath)
	files.writeBytes(filePath, r)
}
function getProjectFileList(projectName) {
	var url = util.format('http://%s:3000/fileSync/project/fileList/', computerIP, projectName)
	url = url.replace(/\s/g, '')
	console.log(url)
	var r = http.get(url)
	r = r.body.json()
	return r
}
